
<div class="form">
    <?php echo CHtml::beginForm(); ?>

    <div class="row">
        <?php date_default_timezone_set('America/Lima'); ?>
        <?php echo CHtml::label('Algo', 'texto'); ?>
        <?php echo CHtml::textField('texto', date('H:i:s')); ?>
    </div>

    <?php 
    echo CHtml::ajaxSubmitButton('Enviar', array('jp/updateHola'), array('update' => '#datorecarga',));
    ?>

    <?php echo CHtml::endForm(); ?>
</div>

<?php
//echo CHtml::ajaxButton ("Actualizar cadena", CController::createUrl('jp/updateHola/'.$txt), array('update' => '#datorecarga'));
?>

<div id="datorecarga">
    <?php $this->renderPartial('_hola', array('cadena' => $cadena, 'check' => $check)); ?>    
</div>
<br>


<?php
$date1 = '28/10/2013';
$date2 = '02/11/2013';
$id = 1;
//$i = strtotime(date('d/m/Y', strtotime($date)));
//$hoynum = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m", $i), date("d", $i), date("Y", $i)), 0) + 1;
//echo $hoynum;
?>

<?php

list($dia, $mes, $anho) = explode("/", $date1);
$date1 = date("Y-m-d", mktime(0, 0, 0, $mes, $dia, $anho));

list($dia, $mes, $anho) = explode("/", $date2);
$date2 = date("Y-m-d", mktime(0, 0, 0, $mes, $dia, $anho));

$criteria = new CDbCriteria;
$criteria->select = '*';
$criteria->condition = 'fecha>=:fecha_lun AND fecha<=:fecha_vie AND persona_idPersona=:idJp AND estado="libre"';
$criteria->params = array(':fecha_lun' => $date1,
    ':fecha_vie' => $date2,
    ':idJp' => $id
);
$criteria->order = 'fecha ASC, hora ASC';

//$datos['disponibilidadJP'] = Disponibilidad::model()->findAll($criteria);
$disponibilidad = Disponibilidad::model()->findAll($criteria);
//print_r($disponibilidad);
?>

<br>
<table>
    <tr>
        <th>JP</th>
        <th>Fecha</th>
        <th>Hora</th>
        <th>Estado</th>
    </tr>
<?php
foreach ($disponibilidad as $aa) {
    //foreach ($aa as $v) {
        ?>
            <tr>
                <td><?php echo $aa->persona_idPersona; ?></td>
                <td><?php echo $aa->fecha; ?></td>
                <td><?php echo $aa->hora; ?></td>
                <td><?php echo $aa->estado; ?></td>
            </tr>            
    <?php //}
}
?>
</table>